<%@page import="cn.cjyll.C3P0DataSoure.JDBCUtilsC3P0"%>
<%@page import="org.apache.commons.dbutils.QueryRunner"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<jsp:include page="head.jsp" />
<body class="page-body">
<jsp:include page="nav.jsp" />

<%
		String day = request.getParameter("dd_d");
        request.setAttribute("dd_d", day);               // 设置订单的总天数
		String jg = request.getParameter("dd_p");
		request.setAttribute("jg", jg);               // 设置订单总价
		String ll = request.getParameter("dd_l");
		 request.setAttribute("dd_l", ll);               // 设置订单总流量
		 String ddx = request.getParameter("dd_x");
		 request.setAttribute("dd_x", ddx);           //  是否显示
		String name = request.getParameter("username");
//  生成订单编号
        Calendar c = Calendar.getInstance(); 
        // 当前年  
        int year = c.get(Calendar.YEAR);  
        String y = String.valueOf(year);
        // 当前月  
        int month = (c.get(Calendar.MONTH)) + 1;  
        String m = String.valueOf(month);
        // 当前月的第几天：即当前日  
        int day1 = c.get(Calendar.DAY_OF_MONTH);  
        String d = String.valueOf(day1);
    
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int min = c.get(Calendar.MINUTE);
        int sec = c.get(Calendar.SECOND);
        String now = year + "年"+month + "月"  +d + "日" + hour + "时" + min + "分" + sec + "秒";
        request.setAttribute("now", now);               //  设置订单提交时间
        
        int ran = new Random().nextInt(1000000000);
        String r = String.valueOf(ran);
        String bh = y+m+d+r;
        request.setAttribute("bh", bh);                 //  设置订单编号
%>
<c:if test="${requestScope.jg!=null }">
<%

QueryRunner qr = new QueryRunner(JDBCUtilsC3P0.getDataSoure());
String sql = "INSERT INTO buylog(bh,username,price,TIME) VALUES(?,?,?,?);";
Object[] o = {bh,name,jg,now };
int col = qr.update(sql, o);

%>
  <div  class="row">
                <div class="col-sm-12">
                    
                  <div class="panel panel-default">
                    <div  class="panel-heading">
                      <h3 align="center" class="panel-title">本次订单合计</h3>
                      
                      <div class="panel-options">
                         </div>
                    </div>

                    <div class="panel-body">
   <p align="center" style="color:red;">${requestScope.Msg }</p>
     <p align="center" style="color:green;">*订单提交成功，请你尽快支付！</p>
                      <div class="table-responsive">          
                      
        <table cellspacing="0" class="table table-small-font table-bordered table-striped">
                                    <!-- 表头 -->
                                   
                                          <tr align="center">
                                          <td>订单编号</td>
                                            <td align="center">订单总价</td>
                                            <td>总计天数</td>
                                            <td >总计流量</td>
                                            <td >下单时间</td>
                                          <td colspan="2">操作</td>
                                           
                                          </tr>
                                      <tr align="center">
                                       <td>${requestScope.bh }</td>
                                        <td>${requestScope.jg }元</td>
                                        <td>${requestScope.dd_d } 天</td>
                                        <td>${requestScope.dd_l } MB</td>
                                         <td>${requestScope.now } </td>
                                       <td align="center">
                                       <button type="submit" class="btn btn-info">  立 即 支 付  </button>
                                       </td><td align="center">
                                        <a href="${pageContext.request.contextPath }/" type="submit" class="btn btn-info">  返 回 我 的 订 单  </a>
                                       </td>
                                        </tr>
                               
                      
                                
                                  </table>
</div></div></div></div></div></c:if><p align="center"><c:out value="${requestScope.dd_x }">暂时没有提交的订单哦！</c:out></p>

<jsp:include page="copy.jsp" />